﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace ZX.HIS.UI.Controllers
{
    public class HospitalController : Controller
    {
        //
        // GET: /Hospital/

        public ActionResult Index()
        {
            ZX.HIS.BLL.Hospital bll = new ZX.HIS.BLL.Hospital();

            ZX.HIS.Model.UserInfo UserInfo = Session["UserInfo"] as ZX.HIS.Model.UserInfo;
            int UserId = 0;
            HttpCookie myCookie = Request.Cookies["MyCookie"];
            if (myCookie != null)
            {
                if (!String.IsNullOrEmpty(myCookie["UserId"]))
                {
                    UserId = Convert.ToInt32(myCookie["UserId"]);
                }
            }
            List<ZX.HIS.Model.Hospital> Hospital = bll.model(UserId);
            return View(Hospital);
        }

        public ActionResult updaHospital()
        {
            ZX.HIS.BLL.Hospital bll = new ZX.HIS.BLL.Hospital();
            HttpCookie myCookie = Request.Cookies["MyCookie"];
            int UserId = 0;
            if (myCookie != null)
            {
                if (!String.IsNullOrEmpty(myCookie["UserId"]))
                {
                    UserId = Convert.ToInt32(myCookie["UserId"]);
                }
            }
            List<ZX.HIS.Model.Hospital> Hospital = bll.model(UserId);


            return View(Hospital);
        }

        /// <summary>
        /// 诊所修改
        /// </summary>
        /// <returns></returns>
        public int updaHospitaldo()
        {
            ZX.HIS.BLL.Hospital bll = new ZX.HIS.BLL.Hospital();
            string HospitalName = Request["HospitalName"].ToString();
            string HospitalAddre = Request["HospitalAddre"].ToString();
            int HospitalId = Convert.ToInt32(Request["HospitalId"]);

            if (bll.updaHospital(HospitalName, HospitalAddre, HospitalId) > 0)
            {
                return 1;
            }
            else
            {
                return 0;
            }
        }

    }
}
